<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="HNUST/../../user/css/pintuer.css">
<link rel="stylesheet" href="HNUST/../../user/css/admin.css">
<script src="HNUST/../../user/js/jquery.js"></script>
<script src="HNUST/../../user/js/pintuer.js"></script>
<script type="text/javascript">
	function delmessage(id){
		if(confirm("确认要删除么？")){
			$.ajax({
				url:"/HNUST/message/delmessage",
				type:"GET",
				data:{id:id},
				dataType:"json",
				
				success:function(data){
					alert("删除成功！");
					location.reload(true);
				},
				error:function(data){
					alert(data+"删除失败！");
				}
			});
		}
	}
</script>
</head>
<body>

	<div class="panel admin-panel">
		<div class="panel-head">
			<strong class="icon-reorder"> 留言管理</strong>
		</div>
		<div class="padding border-bottom">
			<div class="padding border-bottom">
				<form action="selectmh?" method="post">
					<ul class="search" style="padding-left: 10px;">
						<li><a class="button border-main icon-plus-square-o"
							href="messageAdd"> 添加内容</a></li>
						<li><input type="text" placeholder="请输入搜索关键字"
							name="message_name" class="input"
							style="width: 250px; line-height: 17px; display: inline-block" />
							<button class="button bg-main icon-check-square-o" type="button">
								搜素</button></li>

					</ul>
				</form>
			</div>
		</div>
		<form method="post" action="">
			<table class="table table-hover text-center">
				<tr>
					<th width="120">ID</th>
					<th>姓名</th>
					<th width="25%">内容</th>
					<th width="120" align="center">留言时间</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${message }" var="messages" varStatus="status">
					<tr>
						<td>${status.index+1 }</td>
						<td>${messages.message_name }</td>
						<td align="center">${messages.message_board }</td>
						<td>${messages.message_time }</td>
						<td><div class="button-group">
						<button class="button bg-main icon-trash-o" onclick="delmessage(${messages.message_id});">删除</button>
						
						<a class="button border-main" href="Messagesupdate?message_name=${messages.message_name }"><span class="icon-edit"></span> 修改</a>
							</div></td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="8"><div class="pagelist">
							<!-- 分页功能 start -->
							<div align="center">
								<font size="2">共 ${page.totalPageCount} 页</font> <font size="2">第
									${page.pageNow} 页</font> <a href="queryAll?pageNow=1">首页</a>
								<c:choose>
									<c:when test="${page.pageNow - 1 > 0}">
										<a href="queryAll?pageNow=${page.pageNow - 1}">上一页</a>
									</c:when>
									<c:when test="${page.pageNow - 1 <= 0}">
										<a href="queryAll?pageNow=1">上一页</a>
									</c:when>
								</c:choose>
								<c:choose>
									<c:when test="${page.totalPageCount==0}">
										<a href="queryAll?pageNow=${page.pageNow}">下一页</a>
									</c:when>
									<c:when test="${page.pageNow + 1 < page.totalPageCount}">
										<a href="queryAll?pageNow=${page.pageNow + 1}">下一页</a>
									</c:when>
									<c:when test="${page.pageNow + 1 >= page.totalPageCount}">
										<a href="queryAll?pageNow=${page.totalPageCount}">下一页</a>
									</c:when>
								</c:choose>
								<c:choose>
									<c:when test="${page.totalPageCount==0}">
										<a href="queryAll?pageNow=${page.pageNow}">尾页</a>
									</c:when>
									<c:otherwise>
										<a href="queryAll?pageNow=${page.totalPageCount}">尾页</a>
									</c:otherwise>
								</c:choose>
							</div>
							<!-- 分页功能 End -->
						</div></td>
				</tr>
			</table>
	</div>
	</form>
</body>
</html>